package edu.nf.project.entitys.entity.storeOperation.convention.operate;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.nf.project.entitys.enums.storeOperation.OrderStatusEnum;
import edu.nf.project.entitys.enums.storeOperation.OrderTypeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单主表（customer_order）
 * 展示订单的基本信息
 */
@Data
@NoArgsConstructor
@TableName("customer_order")
public class CustomerOrder {
    /**
     * 订单编号
     */
    @TableId(type = IdType.AUTO)
    private Integer orderId;

    /**
     * 所属餐桌
     */
    private Integer boardId;

    /**
     * 总金额
     */
    private BigDecimal totalAmount;

    /**
     * 优惠金额
     */
    private BigDecimal discountAmount;

    /**
     * 实付金额
     */
    private BigDecimal payableAmount;

    /**
     * 订单类型
     */
    private OrderTypeEnum orderType;

    /**
     * 订单状态（默认：待支付）
     */
    private OrderStatusEnum orderStatus = OrderStatusEnum.TO_BE_PAID;

    /**
     * 下单时间
     */
    private Date placeOrderTime;

    /**
     * 支付时间（默认：null）
     */
    private Date paymentTime = null;

    /**
     * 订单备注（默认：""）
     */
    private String remark = "";

    /**
     * 配送地址（默认：""表示堂食）
     */
    private String shippingAddress = "";

    /**
     * 操作人
     */
    @JsonProperty("uId")
    private Integer uId;

    public CustomerOrder(CustomerOrder order){
        this.orderId = order.getOrderId();
        this.boardId = order.getBoardId();
        this.totalAmount = order.getTotalAmount();
        this.discountAmount = order.getDiscountAmount();
        this.payableAmount = order.getPayableAmount();
        this.orderType = order.getOrderType();
        this.orderStatus = order.getOrderStatus();
        this.placeOrderTime = order.getPlaceOrderTime();
        this.paymentTime = order.getPaymentTime();
        this.remark = order.getRemark();
        this.shippingAddress = order.getShippingAddress();
        this.uId = order.getUId();
    }
}
